import Cookies from "js-cookie";

export const TokenKey = 'TokenKey_token_take_out'
export const usercolor = '#FB766A'

export const emcolor = '#3CB79A'

export function getThemColor() {
    if (getRole() === 'em') {
        return emcolor
    } else {
        return usercolor
    }
}

export function getToken() {
    return JSON.parse(Cookies.get(TokenKey))
}

export function getTokenId() {
    return JSON.parse(Cookies.get(TokenKey)).id
}

export function setToken(token) {
    return Cookies.set(TokenKey, token)
}

export function removeToken() {
    return Cookies.remove(TokenKey)
}


const RoleKey = 'RoleKey_take_out'

export function getRole() {
    return Cookies.get(RoleKey)
}

export function setRole(role) {
    return Cookies.set(RoleKey, role)
}

export function removeRole() {
    return Cookies.remove(RoleKey)
}

const AddressKey = 'AddressKey_take_out'

export function setAddress(item) {
    return Cookies.set(AddressKey, JSON.stringify(item))
}

export function getAddress() {

    return JSON.parse(Cookies.get(AddressKey)||'{}')
}

